package org.wattdepot.cli;


import java.io.IOException;
import java.util.List;
import org.wattdepot.client.WattDepotClientException;
import javax.xml.datatype.XMLGregorianCalendar;

/**
 * List of method prototypes for DataExtraction class.
 * @author wattdepot-cli-ewalu group
 *
 */
public interface ExtractionInterface {
  
  /**
   * Returns a string containing a list of all public sources available on this server.
   * 
   * @return A list of sources as a string.
   * @throws WattDepotClientException If problems occur obtaining the list of sources. 
   */
  public String getSourcesInfo() throws WattDepotClientException;
  
  /**
   * Obtain subsources of the desired source.
   * @param plant source of power
   * @return The source's subsources. 
   * @throws WattDepotClientException If problems occur getting the source index. 
   */
  public String getSubSource(String plant) throws WattDepotClientException;
  
  /**
   * Obtain description of the desired power source.
   * @param plant power source 
   * @return description of power source
   * @throws WattDepotClientException If problems occur getting the source index. 
   */
  public String getDetail(String plant) throws WattDepotClientException;
  
  /**
   * Obtain owner's name of desired power source.
   * @param plant power source 
   * @return owner of power source
   * @throws WattDepotClientException If problems occur getting the source index. 
   */
  public String getPerson(String plant) throws WattDepotClientException;
  
  /**
   * Obtain location of the desired power source.
   * @param plant power source 
   * @return location of power source
   * @throws WattDepotClientException If problems occur getting the source index.
   */
  public String getPlace(String plant) throws WattDepotClientException;
  
  /**
   * Obtain coordinates of desired power source.
   * @param plant power source 
   * @return coordinates of power source
   * @throws WattDepotClientException If problems occur getting the source index.
   */
  public String getPlaceCoordinates(String plant) throws WattDepotClientException;
  
  /**
   * Obtain property values of desired power source.
   * @param plant power source 
   * @return attribute values of power source
   * @throws WattDepotClientException If problems occur getting the source index.
   */
  public String getAttribute(String plant) throws WattDepotClientException;
  
  /**
   * Obtain the earliest data reported from the desired source.
   * @param plant power source 
   * @return time earliest data of power source
   * @throws WattDepotClientException If problems occur getting the source index.
   */
  public String getData(String plant) throws WattDepotClientException;
  
  /**
   * Obtain SensorData information regarding desired power source.
   * @param plant The power source
   * @param request The time of the power source.  
   * @return the information of the power source 
   */
  public String getSensorInfo(String plant, XMLGregorianCalendar request);
  
  /**
   * Create time requested by client.
   * @param requestTime The time we want to get sensor data from.  
   * @return the time in XMLGregorianCalendar type. 
   * @throws WattDepotClientException If problems occur during operation. 
   */
  public XMLGregorianCalendar getTime(String requestTime) throws WattDepotClientException;
  
  /**
   * Prints the options with description that can be
   * used for this commandline interface.
   * @return the long string of commands to be used as is.
   */
  public String printHelp();
  
  /**
   * Obtain power generated or consumed by requested source at specified time.
   * @param choice -generated or consumed
   * @param plant source
   * @param request specified time
   * @return the power generated or consumed that time for that power source.
   * @throws WattDepotClientException If problems occur during operation.
   */
  public String getPowerInfo(String choice, String plant, XMLGregorianCalendar request) throws
    WattDepotClientException;
  
  /**
   * Obtains the list of sources.
   * @return the list of sources.
   * @throws WattDepotClientException If problems occur during operation.
   */
  public StringBuffer listSources() throws WattDepotClientException;
 
  /**
   * Lists the sensor data of the specific date. 
   * 
   * @param sourceName is the name of the source.
   * @param day specifies the day to look for.
   * @throws WattDepotClientException If anything goes wrong.
   * @return a list of sensor data.
   */
  public StringBuffer listSensorDataByDate(String sourceName, String day) 
    throws WattDepotClientException;

  /**
   * 
   * @param option defines the option available for this method.
   * @param sourceName is the name of the source instance.
   * @param day is the date input.
   * @param intervalStr is the string representation of the interval.
   * @param statistic defines what the type of output.
   * @return either max, min, or average value of the output.
   * @throws WattDepotClientException If something goes wrong.
   */
  public String listPower(String option, String sourceName, String day, String intervalStr,
      String statistic) throws WattDepotClientException;
  
  /**
   * Returns the largest value in the List.
   * @param list is the List of Double.
   * @return returns the largest element within the list.
   */
  public Double getMax(List<Double> list);
  
  /**
   * Returns the smallest value in the List.
   * @param list is the List of Double.
   * @return returns the smallest element within the list.
   */
  public Double getMin(List<Double> list);
  
  /**
   * Calculates the average value of all the list values.
   * @param list is the List of Double.
   * @return returns the average value of the elements in the list.
   */
  public Double getAverage(List<Double> list);
  /**
   * Gets the total amount of carbon or energy emitted.
   * 
   * @param option defines whether to return carbon emission or energy consumption.
   * @param choice generated or consumed in energy.
   * @param sourceName is the name of the source.
   * @param day is the date input.
   * @param intervalStr is the sampling interval in String format.
   * @return returns the total carbon emissions or energy consumption within a day.
   * @throws WattDepotClientException If anything goes wrong.
   */
  public String listTotal(String option, String choice, String sourceName, 
    String day, String intervalStr) throws WattDepotClientException;
  
  
  /**
   * Charts the power data.
   * 
   * @param option defines whether to chart power or energy generated.
   * @param sourceName is the name of the source instance.
   * @param startDay is the beginning date.
   * @param endDay is the end date.
   * @param intervalStr is the interval value in String format.
   * @param filename is the name of the file to output to.
   * @return returns the current directory and the output filename upon success.
   * @throws WattDepotClientException If anything goes wrong.
   * @throws IOException if anything goes wrong.
   */
  public String chartPower(String option, String sourceName, String startDay, String endDay, 
    String intervalStr, String filename) throws WattDepotClientException, IOException;
  

 /**
   * Checks for the subsources of the input source and returns a list
   * of sources grouped by fuel type.
   * @param sourceName the desired source
   * @return a list of sources grouped by fuel type.
   * @throws WattDepotClientException If info cannot be retrieved.
   */
  public StringBuffer getFueltype(String sourceName) throws WattDepotClientException;

  /**
   * Give the total power associated with the fuel type and source.
   * @param input the desired source
   * @param plant is the desired public source
   * @param request is the time to retrieve info.
   * @param fuelType is the type of fuel of source
   * @return a string that displays the total power
   * @throws WattDepotClientException If info cannot be retrieved.
   */
  public String totalPower(String input,String plant, XMLGregorianCalendar request, 
    String fuelType) throws WattDepotClientException;


/**
   * Returns the calculated value of carbon content.
   * @param sourceName the desired source
   * @param timestamp is the desired timestamp input.
   * @param interval is the desired interval to calculate the result with.
   * @return a value of the calculated carbon content value.
   * @throws WattDepotClientException If info cannot be retrieved.
   */

public String getCarboncontent(String sourceName, String timestamp, String interval)
  throws WattDepotClientException;
}
